using System.Linq.Expressions;
using GEM.Domain.Entities.App;

namespace GEM.Domain.Repositories;

public interface IRepository<T>
{
    void Attach(T entity);

    /// <summary>
    /// 获取可查询的IQueryable对象
    /// </summary>
    /// <returns>IQueryable对象</returns>
    // IQueryable<T> GetQuer
    /// <summary>
    /// 分页查询
    /// </summary>
    /// <param name="pageIndex">页码</param>
    /// <param name="pageSize">每页条数</param>
    /// <param name="predicate">查询条件</param>
    /// <param name="includes">导航属性</param>
    /// <returns>分页数据</returns>
    Task<(IEnumerable<T> Items, int TotalCount)> GetPagedAsync(
    int pageIndex, int pageSize, params Expression<Func<T, object>>[] includes);

    // 获取所有实体对象，并包含指定的导航属性
    Task<T?> GetSingleWithIncludesAsync(Expression<Func<T, bool>> predicate,
                params Expression<Func<T, object>>[] includes);

    /// 获取指定ID的实体对象，并包含指定的导航属性
    Task<T?> GetByIdWithIncludesAsync(Guid id, params Expression<Func<T, object>>[] includes);


}